package com.example.myblog_springboot.controller;

import cn.hutool.json.JSONObject;
import com.example.myblog_springboot.service.MoNiVannaTrainingDataService;
import oracle.jdbc.proxy.annotation.Post;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/v0/train")
public class MoNiVannaTrainingDataController {

    @Autowired
    private MoNiVannaTrainingDataService moNiVannaTrainingDataService;

    @PostMapping
    public JSONObject trainAdd(@RequestBody Map map) {
        return moNiVannaTrainingDataService.trainAdd(map);
    }

    @DeleteMapping("/{id}")
    public JSONObject trainDelete(@PathVariable String id) {
        boolean b = moNiVannaTrainingDataService.removeById(id);
        if (b) {
            return new JSONObject().set("code", 200).set("msg", "删除成功");
        }
        return new JSONObject().set("code", 500).set("msg", "删除失败");
    }
}
